<%-- 
    Document   : ConferenceForm
    Created on : Nov 30, 2012, 9:30:06 PM
    Author     : Gary
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s"%>

<s:if test="conference==null">
    <s:set name="title" value="Add Conference"/>
</s:if>
<s:else>
    <s:set name="title" value="Update Conference"/>
</s:else>
<!DOCTYPE html>
<html>
    <head>
       
        <link href="<c:url value='/css/main.css'/>" rel="stylesheet" type="text/css"/>
        <link href="<c:url value="/css/jquery-ui-1.9.2.custom.min.css" />" rel="stylesheet" type="text/css" />
        <style>td { white-space:nowrap; }</style>
        <script type="text/javascript" src="<c:url value="/scripts/jquery.js" />" ></script>
        <script type="text/javascript" src="<c:url value="/scripts/jquery-ui-1.9.2.custom.min.js" />" ></script>
        <title><s:property value="#title"/></title>
        <script>    
            $(document).ready(function(){              
                $(".datepicker").attr("readonly","readonly").datepicker();
                var callPaper = <s:if test ="conference.callForPaper == true">  true;</s:if> <s:else> false; </s:else> 
                var notifyResults = <s:if test="conference.notifyResults == true"> true; </s:if><s:else> false;</s:else> 
                var availableType = <s:property value="conference.conferencetype" />;
                $("#chkCallForPaper")[0].checked = callPaper;
                $("#chknotifyResults")[0].checked = notifyResults; 
                
                if ((1 & availableType)  == 1) $("#type1")[0].checked = true; 
                if ((2 & availableType)   == 2) $("#type2")[0].checked = true; 
                if ((4 & availableType)  == 4) $("#type3")[0].checked = true; 
                if ((8 & availableType)  == 8) $("#type4")[0].checked = true; 
                
                var isUpdate = <s:property value="isUpdate" />;
                if (isUpdate)
                    {
                        $("#conferenceName").attr("readonly","readonly");
                    }
            });
            
            function prepareSubmit()
            {
                $("#callForPaper").val($("#chkCallForPaper")[0].checked);
                $("#notifyResults").val($("#chknotifyResults")[0].checked);
                
                var type1 =$("#type1")[0].checked? $("#type1").val() - 0 : 0 ;
                var type2 =$("#type2")[0].checked?  $("#type2").val() - 0: 0 ;
                var type3 =$("#type3")[0].checked?  $("#type3").val() - 0 : 0;
                var type4 =$("#type4")[0].checked?  $("#type4").val() - 0 : 0;
 
                var finialType = ((type1 | type2) | type3) | type4; 
                $("#conferencetype").val(finialType);
            }
        </script>
    </head>
    <body>
        
        <h1><s:property value="#title"/></h1>
        <s:form namespace="/conference" action="update_%{conference.conferenceName}">
			<s:actionerror/>
            <table>
                <tr>
                    <td class="tdLabel"><b>Conference Name:</b></td>
                    <td>
                        <input type="text" name="conference.conferenceName" id="conferenceName" value="<s:property value="conference.conferenceName" />" size="20" />             
                    </td>
                </tr>
                <tr>
                    <td class="tdLabel"><b>Event Detail:</b></td>
                    <td>
                        <input type="text" size="40" name="conference.eventDetail" id="conference.eventDetail" value="<s:property value="conference.eventDetail" />" />
                    </td>
                </tr>
                
                <tr>
                    <td class="tdLabel"><b>Location:</b></td>
                    <td>
                        <input type="text" size="60" name="conference.locatoin" id="conference.locatoin" value="<s:property value="conference.locatoin" />" />
                    </td>
                </tr>
                
                <tr>
                    <td class="tdLabel"><b>Call For Paper:</b></td>
                    <td>
                        <input type="checkbox"  id="chkCallForPaper" />
                        <input type="hidden" name="conference.callForPaper" id="callForPaper" value=""/>
                   </td>
                </tr>
                <tr>
                    <td class="tdLabel"><b>Notify Results:</b></td>
                    <td>
                        <input type="checkbox" id="chknotifyResults"  />
                        <input type="hidden"  name="conference.notifyResults" id="notifyResults" value="" />
                   </td>
                </tr>
                
                <tr>
                    <td class="tdLabel"><b>Price:</b></td>
                    <td>
                        <input type="text" size="60" name="conference.price" id="conference.price" value="<s:property value="conference.price" />" />
                    </td>
                </tr>
                <tr>
                    <td class="tdLabel"><b>Open Window:</b> </td>
                     <td>
                      From :  <input class="datepicker" type="text" name="openFrom" id="timeline.holdFrom"  
                                    value=" <s:date name="timeline.holdFrom" format="MM/dd/yyyy" />" />
                      
                     
                      
                      To : <input class="datepicker" type="text" name="openTo" id="timeline.holdTo" 
                                  value=" <s:date name="timeline.holdTo" format="MM/dd/yyyy" />" />
                    </td>
                </tr>
                <tr>
                    <td class="tdLabel"><b>Register Window : </b></td>
                    <td>
                      From :   <input type="text"  class="datepicker" name="registerFrom" id="timeline.registerFrom" 
                               value="<s:date name="timeline.registerFrom" format="MM/dd/yyyy" />" />
                      To :   <input type="text"  class="datepicker" size="20" name="registerTo" id="timeline.registerTo" 
                               value="<s:date name="timeline.registerTo" format="MM/dd/yyyy" />" />
                    </td>
                </tr>
                <tr>
                    <td class="tdLabel"><b>Available Item Type:</b></td>
                    <td>
                <lable for="type1">Paper Prensentation</lable><input type="checkbox" id="type1" value="1" />
                        <lable for="type2">workshop</lable><input type="checkbox" id="type2" value="2"/>
                        <lable for="type3">Doctoral Symposium</lable><input type="checkbox" id="type3"  value="4"/>
                        <lable for="type4">Tutorial</lable><input type="checkbox" id="type4"  value="8"/>
                        <input type="hidden" name="conference.conferencetype" id="conferencetype" value="" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align: center">
                        <input type="hidden" name="update" value="<s:property value="isUpdate" />" />
                        <input type="submit" id="update_<s:property value="conference.conferenceName"/>_0" value="Submit" onclick="prepareSubmit();"/>
                        <input type="submit" id="update_<s:property value="conference.conferenceName"/>_Cancel" name="action:list_all" value="Cancel"/>    
                    </td>
                </tr>
            </table>
        </s:form>
        
        <s:fielderror ><s:param>updateMessage</s:param></s:fielderror>
    </body>
</html>
